// 认证相关常量

// Store ID
export const STORE_IDS = {
    USER: 'user'
} as const

// LocalStorage 键名
export const STORAGE_KEYS = {
    TOKEN: 'token',
    ROLES: 'roles',
    USERNAME: 'username',
    NICKNAME: 'nickname',
    MENU: 'menu',
    X_TOKEN: 'X-Token'
} as const

// 默认值
export const DEFAULT_VALUES = {
    TOKEN: '',
    ROLES: [],
    USERNAME: '',
    NICKNAME: '',
    MENU: [],
    X_TOKEN: ''
} as const

// 错误消息
export const ERROR_MESSAGES = {
    LOGIN_FAILED: '登录失败:',
    LOGIN_EXPIRED: '登录状态过期',
    PLEASE_RELOGIN: '请重新登录',
    ERROR: 'Error'
} as const

// HTTP状态码
export const HTTP_STATUS = {
    SUCCESS: 200,
    UNAUTHORIZED: 401
} as const

// 通知类型
export const NOTIFICATION_TYPES = {
    ERROR: 'error',
    WARNING: 'warning'
} as const

// 路由路径
export const ROUTE_PATHS = {
    LOGIN: '/login'
} as const

// 延迟时间（毫秒）
export const DELAY_TIMES = {
    LOGIN_REDIRECT: 1500,
    NOTIFICATION_DURATION: 3000
} as const

// 接口类型定义
export interface LoginParams {
    username: string
    password: string
}

// 用户信息类型
export interface UserInfo {
    username: string
    roles: string[]
    nickname: string
}

// 登录响应类型
export interface LoginResponse {
    token: string
    user: UserInfo
    menulist: any[]
}

// 工具函数
export const getStorageItem = (key: string): string => {
    return localStorage.getItem(key) || ''
}

export const getStorageArray = (key: string): any[] => {
    const item = localStorage.getItem(key)
    return item ? JSON.parse(item) : []
}

export const setStorageItem = (key: string, value: string): void => {
    localStorage.setItem(key, value)
}

export const setStorageArray = (key: string, value: any[]): void => {
    localStorage.setItem(key, JSON.stringify(value))
}

export const clearStorageItem = (key: string): void => {
    localStorage.removeItem(key)
} 